package example;

import com.alibaba.fastjson2.JSONObject;
import com.ctg.faas.runtime.Context;
import com.ctg.faas.runtime.PojoRequestHandler;
import example.model.SimpleResponse;

import java.util.List;
import java.util.logging.Logger;

/**
 * Kafka触发器事件函数
 */
public class KafkaHandler implements PojoRequestHandler<List<JSONObject>, SimpleResponse> {
    private static final Logger logger = Logger.getLogger(KafkaHandler.class.getName());

    @Override
    public SimpleResponse handleRequest(List<JSONObject> input, Context context) {
        String body = (input == null) ? "" : input.toString();
        logger.info("Received request: " + body);
        // 执行相关业务逻辑...
        return new SimpleResponse(body);
    }
}
